package net.lab1024.sa.base.module.support.soaraction.controller;

import net.lab1024.sa.base.common.domain.ValidateList;
import net.lab1024.sa.base.module.support.soaraction.domain.form.SoarActionAddForm;
import net.lab1024.sa.base.module.support.soaraction.domain.form.SoarActionQueryForm;
import net.lab1024.sa.base.module.support.soaraction.domain.form.SoarActionUpdateForm;
import net.lab1024.sa.base.module.support.soaraction.domain.vo.SoarActionVO;
import net.lab1024.sa.base.module.support.soaraction.service.SoarActionService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * chenyuqiang Controller
 *
 * @Author chenyuqiang
 * @Date 2025-09-15 23:07:17
 * @Copyright 1
 */

@RestController
@Tag(name = "chenyuqiang")
public class SoarActionController {

    @Resource
    private SoarActionService soarActionService;

    @Operation(summary = "分页查询 @author chenyuqiang")
    @PostMapping("/soarAction/queryPage")
    @SaCheckPermission("soarAction:query")
    public ResponseDTO<PageResult<SoarActionVO>> queryPage(@RequestBody @Valid SoarActionQueryForm queryForm) {
        return ResponseDTO.ok(soarActionService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author chenyuqiang")
    @PostMapping("/soarAction/add")
    @SaCheckPermission("soarAction:add")
    public ResponseDTO<String> add(@RequestBody @Valid SoarActionAddForm addForm) {
        return soarActionService.add(addForm);
    }

    @Operation(summary = "更新 @author chenyuqiang")
    @PostMapping("/soarAction/update")
    @SaCheckPermission("soarAction:update")
    public ResponseDTO<String> update(@RequestBody @Valid SoarActionUpdateForm updateForm) {
        return soarActionService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author chenyuqiang")
    @PostMapping("/soarAction/batchDelete")
    @SaCheckPermission("soarAction:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Integer> idList) {
        return soarActionService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author chenyuqiang")
    @GetMapping("/soarAction/delete/{id}")
    @SaCheckPermission("soarAction:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Integer id) {
        return soarActionService.delete(id);
    }
}
